package com.youlu.campus.admin.group.controller;

import com.youlu.campus.admin.group.dto.GroupQueryRequest;
import com.youlu.campus.admin.group.dto.GroupRequest;
import com.youlu.campus.admin.group.dto.GroupResponse;
import com.youlu.campus.admin.group.service.GroupService;
import com.youlu.campus.admin.utils.AuthUtils;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 小组管理
 * @author: YangJ
 * @date: 2020/12/29 10:06
 */
@RestController
public class GroupController {

    @Autowired
    private GroupService groupService;

    /**
     * 小组列表
     * @param request 小组信息查询请求类
     * @return 请求成功时返回GroupResponse对象
     */
    @PostMapping("/group/list")
    public QResult list(@RequestBody GroupQueryRequest request){
        return QResult.success(groupService.list(request));
    }

    /**
     * 小组解散
     * @param request 小组解散请求类
     * @return
     */
    @PostMapping("/group/dissolution")
    public QResult dissolution(@RequestBody GroupRequest request){
        request.setUserId(AuthUtils.getUserId());
        return QResult.success(groupService.dissolution(request));
    }
}